#include "CGIRenderPass.h"

namespace Alice
{
    void CGIRenderPassInfo::ConvertToRenderTargetsInfo(CGISetRenderTargetsInfo& OutRTInfo) const
	{
		int32 index=0;
		OutRTInfo.mColorRenderTarget[index]->Texture = mColorRenderTargets.RenderTarget;
		ERenderTargetLoadAction LoadAction = GetLoadAction(mColorRenderTargets.Action);
		OutRTInfo.mColorRenderTarget[index]->LoadAction = LoadAction;
		OutRTInfo.mColorRenderTarget[index]->StoreAction = GetStoreAction(mColorRenderTargets.Action);
		OutRTInfo.mColorRenderTarget[index]->ArraySliceIndex = mColorRenderTargets.ArraySlice;
		OutRTInfo.mColorRenderTarget[index]->MipIndex = mColorRenderTargets.MipIndex;
		++OutRTInfo.NumColorRenderTargets;

		OutRTInfo.bClearColor |= (LoadAction == ERenderTargetLoadAction::EClear);
		
		/*for (int32 Index = 0; Index < MaxSimultaneousRenderTargets; ++Index)
		{
			if (!mColorRenderTargets[Index].RenderTarget)
			{
				break;
			}

			OutRTInfo.ColorRenderTarget[Index].Texture = ColorRenderTargets[Index].RenderTarget;
			ERenderTargetLoadAction LoadAction = GetLoadAction(ColorRenderTargets[Index].Action);
			OutRTInfo.ColorRenderTarget[Index].LoadAction = LoadAction;
			OutRTInfo.ColorRenderTarget[Index].StoreAction = GetStoreAction(ColorRenderTargets[Index].Action);
			OutRTInfo.ColorRenderTarget[Index].ArraySliceIndex = ColorRenderTargets[Index].ArraySlice;
			OutRTInfo.ColorRenderTarget[Index].MipIndex = ColorRenderTargets[Index].MipIndex;
			++OutRTInfo.NumColorRenderTargets;

			OutRTInfo.bClearColor |= (LoadAction == ERenderTargetLoadAction::EClear);

			if (ColorRenderTargets[Index].ResolveTarget)
			{
				OutRTInfo.bHasResolveAttachments = true;
				OutRTInfo.ColorResolveRenderTarget[Index] = OutRTInfo.ColorRenderTarget[Index];
				OutRTInfo.ColorResolveRenderTarget[Index].Texture = ColorRenderTargets[Index].ResolveTarget;
			}
		}*/

		/*ERenderTargetActions DepthActions = GetDepthActions(DepthStencilRenderTarget.Action);
		ERenderTargetActions StencilActions = GetStencilActions(DepthStencilRenderTarget.Action);
		ERenderTargetLoadAction DepthLoadAction = GetLoadAction(DepthActions);
		ERenderTargetStoreAction DepthStoreAction = GetStoreAction(DepthActions);
		ERenderTargetLoadAction StencilLoadAction = GetLoadAction(StencilActions);
		ERenderTargetStoreAction StencilStoreAction = GetStoreAction(StencilActions);

		OutRTInfo.DepthStencilRenderTarget = FRHIDepthRenderTargetView(DepthStencilRenderTarget.DepthStencilTarget,
			DepthLoadAction,
			GetStoreAction(DepthActions),
			StencilLoadAction,
			GetStoreAction(StencilActions),
			DepthStencilRenderTarget.ExclusiveDepthStencil);
		OutRTInfo.bClearDepth = (DepthLoadAction == ERenderTargetLoadAction::EClear);
		OutRTInfo.bClearStencil = (StencilLoadAction == ERenderTargetLoadAction::EClear);

		if (DepthStencilRenderTarget.ResolveTarget && DepthStencilRenderTarget.ResolveTarget != DepthStencilRenderTarget.DepthStencilTarget)
		{
			OutRTInfo.DepthStencilResolveRenderTarget = OutRTInfo.DepthStencilRenderTarget;
			OutRTInfo.DepthStencilResolveRenderTarget.Texture = DepthStencilRenderTarget.ResolveTarget;
		}

		OutRTInfo.ShadingRateTexture = ShadingRateTexture;
		OutRTInfo.ShadingRateTextureCombiner = ShadingRateTextureCombiner;
		OutRTInfo.MultiViewCount = MultiViewCount;*/
	}
}